/*----------------------------------------------------------
* FILE: GenerateHtmlDecorator.java
* LOGICAL NAME: GenerateHtmlDecorator
* PRODUCT: bila-framework
*----------------------------------------------------------
* MODIFICATIONS
* DATE Oct 10, 2011
* AUTHOR wjuarez
*----------------------------------------------------------
*/

package bila.framework.displaytag.decorator;

import javax.servlet.jsp.PageContext;

import org.displaytag.decorator.DisplaytagColumnDecorator;
import org.displaytag.exception.DecoratorException;
import org.displaytag.properties.MediaTypeEnum;

import bila.framework.commons.GeneralFunction;

/**
 * @author WJuarez
 * <b>Created by </b>wjuarez
 * <b>for</b> bila-framework
 * <b>package</b> bila.framework.displaytag.decorator
 * <b>on</b> Oct 10, 2011 9:26:59 PM
 * <b>Purpose</b> 
 * <p>
 *		Decorator general para los displaytag del sistema
 * </p>
 */
public class GenerateHtmlDecorator implements DisplaytagColumnDecorator{

	/*
	 * (non-Javadoc)
	 * @see org.displaytag.decorator.DisplaytagColumnDecorator#decorate(java.lang.Object, javax.servlet.jsp.PageContext, org.displaytag.properties.MediaTypeEnum)
	 */
	public Object decorate(Object columnValue, PageContext ctx, MediaTypeEnum media) throws DecoratorException {
		String column = null;
		if(columnValue instanceof String)
			column = (String) columnValue;
		try{
			if(column != null)
				column = GeneralFunction.generateHtml(column);
			else
				return columnValue;
		}catch(Exception e){
			e.printStackTrace();
			return columnValue;
		}
		StringBuffer buffer = new StringBuffer();
		buffer.append(column);
		return buffer.toString();
	}
}
